import tbgeo, tbgeoconst
from tbgeo import coordinates, position

f = open('c:/inne/gps/mapy/tb/Polska-pogladowa/mapka.map', 'r')
lines = f.readlines()
f.close()

map = tbgeo.Map()
d = lines[4].split(',')[0]
map.setDatum(d)
p = lines[8].split(',')[1]
map.setProjection(p)      
k = int(lines[39].split(',')[1])
q = zip(lines[40:40 + k], lines[40 + k:40 + k * 2])
maxx = 0
maxy = 0
for (p, c) in q:
    r1 = p.split(',')
    r2 = c.split(',')
    x = int(r1[2].strip())
    maxx = max(maxx, x)
    y = int(r1[3].strip())
    maxy = max(maxy, y)
    lat = float(r2[2].strip())
    lon = float(r2[3].strip())
    map.addCalibrationPoint(lat, lon, x, y)

map.setWidth(maxy)
map.setHeight(maxx)
